//@flow
import React from 'react'
import {
  Router,
  Modal,
  Scene,
} from 'react-native-router-flux'
import {
  Provider,
  connect,
} from 'react-redux'
import Login from './containers/account/login'
import Regist from './containers/account/regist'
import StoryList from './containers/story/storyList'
import ShowStory from './containers/story/showStory'

import TabIcon from './component/tabIcon'

export default function AppRouter({ store, }){
  const RouterWithRedux = connect()(Router)
  return (
    <Provider store={store}>
      <RouterWithRedux>
        <Scene key="modal" component={Modal}>
          <Scene key="root" hideNavBar>
            <Scene key="showStory" component={ShowStory}/>
            <Scene key='regist' component={Regist} title='注册'/>

            <Scene key="login" component={Login} initial/>
            <Scene
              key="main"
              hideNavBar
              tabs
              >
                <Scene
                  key="storyList"
                  icon={() => <TabIcon iconName="rocket" selected tabTitle="发现"/>}
                  component={StoryList}
                  title="故事"
                  hideNavBar
                  />
            </Scene>
          </Scene>
        </Scene>
      </RouterWithRedux>
    </Provider>
  )
}
